package com.bcxj.servicepassengeruser.controller;

import com.bcxj.internalcommon.dto.ResponseResult;
import com.bcxj.internalcommon.dto.VerificationCodeDTO;
import com.bcxj.servicepassengeruser.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName: UserController
 * Package: com.bcxj.servicepassengeruser.controller
 * Description:
 *
 * @Author BCXJ
 * @Create 2024/9/17 23:36
 * @Version 1.0
 * @Since 1.0
 */
@RestController()
@RequestMapping("/user")
@Slf4j
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 用户的注册(如果用不存在)
     * @param verificationCodeDTO
     * @return
     */
    @PostMapping
    public ResponseResult loginOrRegister(@RequestBody VerificationCodeDTO verificationCodeDTO) {
        log.info("用户注册/登录:{}", verificationCodeDTO);
        return userService.loginOrRegister(verificationCodeDTO.getPassengerPhone());
    }


    /**
     *  根据手机号获取用户的信息
     * @param userPhone
     * @return
     */
    @GetMapping()
    public ResponseResult getUserInfo(@RequestParam String userPhone) {
        return userService.getUserInfo(userPhone);
    }

}
